from django.test import TestCase

# Create your tests here.

from multiprocessing import Pool,Process
import time,os
def foo(i):
    time.sleep(2)
    print('in the process',os.getpid())
    return i+100

def call(arg):
    print('-->exec done:',arg,os.getpid())

if __name__ == '__main__':
    pool = Pool(3)
    print("主进程pid:",os.getpid())
    for i in range(10):
        pool.apply_async(func=foo,args=(i,),callback=call)
    print('end')
    pool.close()
    pool.join()



